import { Tween } from 'cc';
import { tween } from 'cc';
import { MeshRenderer } from 'cc';
import { Vec3 } from 'cc';
import { _decorator, Component, Node} from 'cc';
import UtilTool from '../../tools/UtilTool';
const { ccclass, property } = _decorator;

// 球体上的UI脚本
@ccclass('BallUI')
export class BallUI extends Component {
    // @property(Node)
    // abelNode : Node = null; // 球体呼吸节点

    number : number = 0
    material = null

    protected onLoad(): void {
        
    }

    start() {
        // 初始化呼吸节点隐藏
        this.node.active = false
    }

    init(number, tag : string = "") {
        this.number = number
    }

    /**
     * 设置呼吸节点的显示隐藏
     * @param show 是否显示
     */
    setAbelNode(show=false, worldPos){
        Tween.stopAllByTarget(this.node)
        this.node.active = show
        
        if (!show) {
            return
        }

        // setTimeout(() => {
        //     if (this && this.node) {
        //         UtilTool.printLog("设置呼吸节点球号=",this.number)
        //         let angle:Vec3 = this.node.eulerAngles
        //         UtilTool.printLog("设置呼吸节点球号2=",angle.x, angle.y, angle.z)
        //         this.node.setRotationFromEuler(-angle.x, -angle.y, -angle.z)
        //         UtilTool.printLog("设置呼吸节点球号3=",this.node.eulerAngles.x, this.node.eulerAngles.y, this.node.eulerAngles.z)
        //     }
        // }, 10);
        this.node.worldPosition = worldPos
        let tweenScale = tween(this.node)
            .to(0.4, {scale: new Vec3(1.2, 1, 1.2)})
            .to(0.4, {scale: new Vec3(1.05, 1, 1.05)})
            .to(0.4, {scale: new Vec3(1.1, 1, 1.1)})
        
        tween(this.node).repeatForever(tweenScale).start()
    }

   

}

